package semiSupervise;

import jwnl.JWNLDistances;

public class Element {

    String Value;

    Element(String V) {
        Value = V;
    }

    boolean equals(String V) {
        return (this.Value.equals(V.toLowerCase()));
    }

    double distance(Element e, JWNLDistances d) {
        String v1 = this.Value;
        String v2 = e.Value;
        double dSim = d.computeSimilarity(v1, v2) * 100;
        System.out.println("computeSimilarity(" + v1 + ", " + v2 + ")=" + (100 - dSim));
        return dSim;
    }

    double distance(Ensemble e, JWNLDistances d) {
        double dSim = 0.0;
        for (int i = 0; i < e.size(); i++) {
            dSim += this.distance(e.get(i), d);
        }
        return dSim / e.size();
    }

    @Override
    public String toString() {
        return this.Value;
    }

    double distance_plus_proche(Ensemble e, JWNLDistances d) {
        double dSim = 0.0, dMin = 0.0;
        for (int i = 0; i < e.size(); i++) {
            dSim = this.distance(e.get(i), d);
            if (dSim > dMin) {
                dMin = dSim;
            }
        }
        return dSim;
    }
}
